//
//  ViewController.m
//  5-31学习
//
//  Created by 钟纪旺 on 16/5/31.
//  Copyright © 2016年 zjw. All rights reserved.
//

#import "ViewController.h"
#import "OneViewController.h"
#import "ThereViewController.h"
@interface ViewController ()<UITableViewDataSource>{
    
    NSArray *Data;
    
    
}


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    Data = @[@"微信",
             @"支付宝",
             @"银行卡",
             @"客服"
             ];

//    self.navigationController.title = @"我的导航";
//    
//    // self.view.backgroundColor = [UIColor redColor];
//    self.view.backgroundColor = [UIColor orangeColor];
//    self.refreshControl = [UIRefreshControl new];
//    //刷新工具图标增加颜色
//    self.refreshControl.tintColor =[UIColor blueColor];
//    self.refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@"正在刷新" attributes:@{NSForegroundColorAttributeName:[UIColor blueColor]}];
//    //设置文字控制停止器 结束刷新
//    self.navigationItem.rightBarButtonItem =[[UIBarButtonItem alloc]initWithTitle:@"🔘" style:UIBarButtonItemStylePlain target:self action:@selector(onClick:)];
   
}
- (void)onClick:(id)sender{
    
    [self.refreshControl endRefreshing];
    
    
    
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    
    
    return Data.count;
    
    
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
    // cell.textLabel.text = @"联系人";
    //找自己图片
    NSString *imgName =[NSString stringWithFormat:@"%ld",indexPath.row + 1];
    cell.imageView.image =[UIImage imageNamed:imgName];
    //图片切圆
    cell.imageView.layer.cornerRadius = 18;
    cell.imageView.clipsToBounds = YES;
    
    cell.textLabel.text =Data [indexPath.row];
    //给cell加颜色
    // cell.backgroundColor =[UIColor colorWithRed:20*indexPath.row/555.0 green:40*indexPath.row/3300.0 blue:60*indexPath.row/255.0 alpha:1];
    if(indexPath.row ==3){
        UISwitch  *sw =[UISwitch new];
        [sw sizeToFit];
        cell.accessoryView =sw;
    }
    //给cell加箭头
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row ==0 ) {
        ViewController *con = [ViewController new];
        [self.navigationController pushViewController:con animated:YES];
        
    }if (indexPath.row ==1) {
        OneViewController *abc =[OneViewController new];
        [self.navigationController pushViewController:abc animated:YES];
    }if (indexPath.row ==2) {
        ThereViewController *sss =[ThereViewController new];
        [self.navigationController pushViewController:sss animated:YES];
    }
   
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
